Skip to content

Raising for invalid dtype issue #15520 #15576

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed

Raising for invalid dtype issue #15520 #15576

wants to merge 1 commit into from

Conversation

petioptrv
Copy link
Contributor

@petioptrv petioptrv commented Mar 5, 2017

closes #15520

  • closes #xxxx
  • tests added / passed
  • passes git diff upstream/master | flake8 --diff
  • whatsnew entry

Copy link
Contributor

@jreback jreback left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

first thing to always do are tests

@@ -172,6 +172,12 @@ def _validate_dtype(self, dtype):
raise NotImplementedError("compound dtypes are not implemented"
"in the {0} constructor"
.format(self.__class__.__name__))

# check if coerced dtype is of type object
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use pandas.types.common.pandas_dtype

@petioptrv
Copy link
Contributor Author

Are you saying I should raise within the pandas_dtype method?

@jreback
Copy link
Contributor

jreback commented Mar 5, 2017

yes pandas_dtype will raise if an invalid string is passed, but not an invalid object

In [1]: pandas.types.common.pandas_dtype(pd.Timestamp)
Out[1]: dtype('O')

In [2]: pandas.types.common.pandas_dtype('foo')
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-2-07647ef910a7> in <module>()
----> 1 pandas.types.common.pandas_dtype('foo')

/Users/jreback/pandas/pandas/types/common.py in pandas_dtype(dtype)
    491         return dtype
    492 
--> 493     return np.dtype(dtype)

TypeError: data type "foo" not understood

@jreback
Copy link
Contributor

jreback commented Mar 10, 2017

if you want to add some tests ping and will reopen

@jreback jreback closed this Mar 10, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: invalid dtypes should raise
2 participants